#!/usr/bin/env python
#coding=utf-8
import sys,urllib
sys.path.append('/home/jay/xiaojaylib/gae')
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'gae_manager.settings'
from gae_manager.host.models import Project

project_name = 'mail_server2'
project = Project.objects.get(name = project_name)

for app in project.app_set.all():
  name = app.app_id
  print name
  url = 'http://%s.appspot.com/count'%name
  data = urllib.urlopen(url).read()
  print data
  if '0' in data: 
    print 'fire!'
    url = 'http://%s.appspot.com/send_mail2'%name
    print urllib.urlopen(url).read()
  
  
  
